function res = GetRelaxationXe131(obj, duration, varargin)
    import MeasurementComponent.Signal.*
    
    p=inputParser;
    p.addRequired('duration', @(x) x>0);
    p.addParameter('rate', 1, @(x) x>0);
    p.addParameter('field', obj.MainField.bz0, @(x) x>0);
    p.addParameter('frequency', obj.Xe131FIDSignal.fft.center, @(x) x>0);
    p.addParameter('amplitude', 1.0, @(x) x>0);
    p.addParameter('flip_time', 2.0, @(x) x>0);
    p.addParameter('isReport', false, @islogical);
    p.addParameter('description', 'normal', @ischar);
    p.parse(duration, varargin{:});
    
    rbSignal = obj.setRFMagnetometer('field', p.Results.field, 'bandwidth', 5);
    
    obj.by131.setAC('frequency', p.Results.frequency, 'amplitude', p.Results.amplitude, 'range', 10); pause(p.Results.flip_time); 
    obj.by131.disableDriver();
    
    rbSignal.subscribe_signal(ziDemodTime.R, [2 1 1]);
    rbSignal.subscribe_signal(ziDemodTime.Theta, [2 1 2]);
    res.signal = rbSignal.getDemodSignal(p.Results.duration, 'rate', p.Results.rate);

    %% Fit: 'untitled fit 1'.
    data = res.signal.getNodeData(2);
    
    if data.y(1) > data.y(end)
        sign = 1.0;
    else
        sign = -1.0;
    end
    
    [xData, yData] = prepareCurveData( data.x, sign * data.y/pi*180 );

    minY = min(yData); maxY = max(yData); 
    a0 = maxY-minY; c0 = minY; tau0 = mean(xData);
    ft = fittype( 'a*exp(-x/tau)+c', 'independent', 'x', 'dependent', 'y' );
    opts = fitoptions( 'Method', 'NonlinearLeastSquares' );
    opts.Display = 'Off';
    opts.Lower =      [0      -Inf   0];
    opts.StartPoint = [a0      c0    tau0];
    opts.Upper =      [10*a0  +Inf   10*tau0];

    [res.fitting.result, res.fitting.gof] = fit( xData, yData, ft, opts );
    res.timestamp = datetime('now');
    obj.Xe131Relaxation = res;

    fig = obj.PlotRelaxationXe131();
    %%
    if p.Results.isReport
        getReporter;
        rpt.NewRecord(['Xe131Relaxation_' p.Results.description]);
        rpt.AppendFigure(fig, sprintf('Xe131Relaxation %s', p.Results.description));
    end
    %%
    getSession;
    sess.addData('Xe131Relaxation', res, p.Results.description);
end

